﻿using System;
using RpcHelper;
using SqlExecHelper;
using SqlExecHelper.SetColumn;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Service.DAL
{
        internal class ContainerDAL : SqlBasicClass
        {
                public ContainerDAL () : base ("ContainerList")
                {

                }

                public ContainerDatum Get (Guid id)
                {
                        return base.GetRow<Guid, ContainerDatum> ("Id", id);
                }

                public BasicContainer[] Gets (Guid[] ids)
                {
                        return base.Get<Guid, BasicContainer> ("Id", ids);
                }
               

                public void SetRemark(Guid id,string remark)
                {
                        if (!base.Update (new ISqlSetColumn[] {
                                new SqlSetColumn("Remark", System.Data.SqlDbType.NVarChar,50){ Value=remark}
                        }, "Id", id))
                        {
                                throw new ErrorException ("rpc.container.remark.set.fail");
                        }
                }

                internal void Delete (Guid id)
                {
                        if (!base.Drop ("Id", id))
                        {
                                throw new ErrorException ("rpc.container.drop.fail");
                        }
                }
        }
}
